use "Measuring Ethnic Inequality Dataset 17-03-2022" 

* NOTE: The do-file requires "worldcoor.dta" to be in the same folder to reproduce Figures with maps 

*************************************
************** Dataset **************
*************************************

*** linear interpolation of Alesina et al (2016)
by country_id: ipolate ethg year, gen(ethg_ip)
by country_id: ipolate grg year, gen(grg_ip)

*** Rename Cederman et al. (2013) data
gen low_ratio = NHIxl if year >=1990

* Rescale V-Dem variable
generate SEI = ((v2peapssoc-3.37)/(-3.135-3.37)*(1-0)+0)

* Generate standardized variables
egen z_ethg =std(ethg), mean(0) std(1)
egen z_ethg_ip =std(ethg_ip), mean(0) std(1)
egen z_low_ratio =std(low_ratio), mean(0) std(1)
egen z_lbgi1 =std(lbgi1), mean(0) std(1)
egen z_SEI =std(SEI), mean(0) std(1)
egen z_ggini =std(ggini), mean(0) std(1)

label variable z_ethg "Alesina et al."
label variable z_ethg_ip "Alesina et al."
label variable z_low_ratio "Cederman et al."
label variable z_lbgi1 "Houle"
label variable z_SEI "V-Dem"
label variable z_ggini "Omoeva et al."
label variable betweenstd "Baldwin and Huber"



********************************************************************************
*********************** Figure 2: Temporal coverage ****************************
********************************************************************************
gen ethg_obs = 1 if ethg!=.
replace ethg_obs=0 if ethg==.

gen low_ratio_obs = 1 if low_ratio!=.
replace low_ratio_obs=0 if low_ratio==.

gen lbgi1_obs = 1 if lbgi1!=.
replace lbgi1_obs=0 if lbgi1==.

gen betweenstd_obs = 1 if betweenstd!=.
replace betweenstd_obs=0 if betweenstd==.

gen ggini_obs = 1 if ggini!=.
replace ggini_obs=0 if ggini==.

gen SEI_obs = 1 if SEI!=.
replace SEI_obs=0 if SEI==.


bys year: egen ethg_total_obs = total(ethg_obs)
recode ethg_total_obs (0=.)
label variable ethg_total_obs "Alesina et al."

bys year: egen low_ratio_total_obs = total(low_ratio_obs)
recode low_ratio_total_obs (0=.)
label variable low_ratio_total_obs "Cederman et al."

bys year: egen lbgi1_total_obs = total(lbgi1_obs)
recode lbgi1_total_obs (0=.)
label variable lbgi1_total_obs "Houle"

bys year: egen betweenstd_total_obs = total(betweenstd_obs)
recode betweenstd_total_obs (0=.)
label variable betweenstd_total_obs "Baldwin and Huber"

bys year: egen SEI_total_obs = total(SEI_obs)
recode SEI_total_obs (0=.)
label variable SEI_total_obs "V-Dem"

bys year: egen ggini_total_obs = total(ggini_obs)
recode ggini_total_obs (0=.)
label variable ggini_total_obs "Omoeva et al."

sort country_id year

twoway (tsline ethg_total_obs, recast(scatter)) (tsline low_ratio_total_obs, recast(scatter)) (tsline lbgi1_total_obs, recast(scatter)) (tsline SEI_total_obs, recast(scatter)) (tsline ggini_total_obs, recast(scatter)) (tsline betweenstd_total_obs, recast(scatter)), xlabel(1900(20)2020, nogrid) ylabel(, nogrid) scheme(plottig) ytitle("No. of countries covered") xtitle("Year") graphregion(lcolor(black) lwidth(tiny))

graph export Figure_2.png, width(4000) replace
		
*****************************************************************
*********** Figure 3: Temporal variation, Bolivia ***************
*****************************************************************

tsline z_ethg z_low_ratio z_lbgi1 z_SEI z_ggini if country_name == "Bolivia", scheme(plottig) xlabel(1900(50)2020, nogrid) ylabel(, nogrid) xtitle("Year") ytitle("Std. score") graphregion(lcolor(black) lwidth(tiny)) name(graph12)
graph display graph12, scale(1.2) ysize(2) xsize(4)

graph export Figure_3.png, width(4000) replace

******************************************************************************
************** Table 3: Correlation analysis *********************************
******************************************************************************

*** Correlation analysis
pwcorr ethg low_ratio lbgi1 betweenstd SEI ggini, obs
matrix list r(C), format(%4.2f)

*** factor analysis (PCA)
factor ethg_ip low_ratio lbgi1 SEI ggini, pcf



************************************************************************************
************* Figure 4: Maps with Alesina et al. and Cederman et al. ***************
************************************************************************************

spmap z_ethg using worldcoor.dta if year ==2000, id(map_id) fcolor(Blues2) osize(vvthin vvthin vvthin vvthin) ndsize(vvthin) clmethod(quantile) title("Alesina et al.") name(map1)
spmap z_low_ratio using worldcoor.dta if year ==2000, id(map_id) fcolor(Blues2) osize(vvthin vvthin vvthin vvthin) ndsize(vvthin) clmethod(quantile) title("Cederman et al.") name(map2)

graph combine map1 map2, rows(2) graphregion(color(white))

graph export Figure_4.png, width(4000) replace

*********************************************************************
************** Figure 5: Replication Alesina et al. 2016 *************
*********************************************************************

* Ensure sample overlap
replace lnrgdppcch2000 =. if year!=2000

* Replication of Alesina et al. 2016: GDP per capita

xi: areg  lnrgdppcch2000 	z_ethg, a(region) robust
eststo m1

xi: areg  lnrgdppcch2000 	z_low_ratio, a(region) robust
eststo m2

xi: areg  lnrgdppcch2000 	z_lbgi1, a(region) robust
eststo m3

xi: areg  lnrgdppcch2000 	z_SEI, a(region) robust
eststo m4

xi: areg  lnrgdppcch2000 	z_ggini, a(region) robust
eststo m5

coefplot (m1, label(Alesina et al.)) (m2, label(Cederman et al.)) (m3, label(Houle)) (m4, label(V-Dem)) (m5, label(Omoeva et al.)), keep(z_ethg z_low_ratio z_lbgi1 z_SEI z_ggini) vertical yline(0) xtitle("") xlabel("") title("") scheme(plottig) graphregion(lcolor(black) lwidth(tiny)) name(graph1)

graph display graph1, scale(1.5) ysize(2) xsize(4)

graph export Figure_5.png, width(4000) replace

************************************************************
************** Figure 6: Replication Houle 2015 *************
************************************************************

*Replication of Houle 2015: Democratic Breakdown

probit autocracy z_ethg_ip lwgi1 c.z_ethg_ip#c.lwgi1 loilincome lethnici lgdptreis lonegrowthtreis lmoslemi lwpch lagedem sizedom western share if ldemocracy==1, cluster(cowcode)
eststo m11

probit autocracy z_low_ratio lwgi1 c.z_low_ratio#c.lwgi1 loilincome lethnici lgdptreis lonegrowthtreis lmoslemi lwpch lagedem sizedom western share if ldemocracy==1, cluster(cowcode)
eststo m12

probit autocracy z_lbgi1 lwgi1 c.z_lbgi1#c.lwgi1 loilincome lethnici lgdptreis lonegrowthtreis lmoslemi lwpch lagedem sizedom western share if ldemocracy==1, cluster(cowcode)
eststo m13

probit autocracy z_SEI lwgi1 c.z_SEI#c.lwgi1 loilincome lethnici lgdptreis lonegrowthtreis lmoslemi lwpch lagedem sizedom western share if ldemocracy==1, cluster(cowcode)
eststo m14

probit autocracy z_ggini lwgi1 c.z_ggini#c.lwgi1 loilincome lethnici lgdptreis lonegrowthtreis lmoslemi lwpch lagedem sizedom western share if ldemocracy==1, cluster(cowcode)
eststo m15

coefplot (m11, label(Alesina et al.)) (m12, label(Cederman et al.)) (m13, label(Houle)) (m14, label(V-Dem)) (m15, label(Omoeva et al.)), keep(z_ethg_ip z_low_ratio z_lbgi1 z_SEI z_ggini) vertical yline(0) xtitle("") xlabel("") title("") scheme(plottig) graphregion(lcolor(black) lwidth(tiny)) name(graph2)

graph display graph2, scale(1.5) ysize(2) xsize(4)

graph export Figure_6.png, width(4000) replace
  
************************************************************************
************** Figure 7: Replication Cederman et al. (2013) *************
************************************************************************

* Replication of Cederman et al. 2013: Civil War (Model 7.1)

global CONTROLS1 ethfrac lpop lgdppcl 
global TIME1 lonshist pyr_NSA NSA_spl*

logit NSAonset z_ethg_ip sip2l mgini_intx max_rexcll  $CONTROLS1 $TIME1 if year>1990, cl(country_id) nolog
eststo m21

logit NSAonset z_low_ratio sip2l mgini_intx max_rexcll $CONTROLS1 $TIME1 if year>1990, cl(country_id) nolog
eststo m22

logit NSAonset z_lbgi1  sip2l mgini_intx max_rexcll $CONTROLS1 $TIME1 if year>1990, cl(country_id) nolog
eststo m23

logit NSAonset z_SEI sip2l mgini_intx max_rexcll $CONTROLS1 $TIME1 if year>1990, cl(country_id) nolog
eststo m24

logit NSAonset z_ggini sip2l mgini_intx max_rexcll $CONTROLS1 $TIME1 if year>1990, cl(country_id) nolog
eststo m25

coefplot (m21, label(Alesina et al.)) (m22, label(Cederman et al.)) (m23, label(Houle)) (m24, label(V-Dem)) (m25, label(Omoeva et al.)), keep(z_ethg_ip z_low_ratio z_lbgi1 z_SEI z_ggini) vertical yline(0) xtitle("") xlabel("") title("") scheme(plottig) graphregion(lcolor(black) lwidth(tiny)) name(graph3)

graph display graph3, scale(1.5) ysize(2) xsize(4)

graph export Figure_7.png, width(4000) replace

**************************************************************************
************** Figure 8: Replication Baldwin and Huber (2010) *************
**************************************************************************

* Replication of Baldwin and Huber 2010: Public Goods

reg pg z_ethg_ip lngdpstd popstd polity2std afrobarom wvs cses, robust
eststo m31

reg pg z_low_ratio lngdpstd popstd polity2std afrobarom wvs cses, robust
eststo m32

reg pg z_lbgi1 lngdpstd popstd polity2std afrobarom wvs cses, robust
eststo m33

reg pg z_SEI lngdpstd popstd polity2std afrobarom wvs cses, robust
eststo m34

reg pg z_ggini lngdpstd popstd polity2std afrobarom wvs cses, robust
eststo m35

reg pg betweenstd lngdpstd popstd polity2std afrobarom wvs cses, robust
eststo m36

coefplot (m31, label(Alesina et al.)) (m32, label(Cederman et al.)) (m33, label(Houle)) (m34, label(V-Dem)) (m35, label(Omoeva et al.)) (m36, label(Baldwin and Huber)), keep(z_ethg_ip z_low_ratio z_lbgi1 betweenstd z_SEI z_ggini) vertical yline(0) xtitle("") xlabel("") title("") scheme(plottig) graphregion(lcolor(black) lwidth(tiny)) name(graph4)

graph display graph4, scale(1.5) ysize(2) xsize(4)

graph export Figure_8.png, width(4000) replace



***************************************************
***************************************************
************ Appendix *****************************
***************************************************
***************************************************




********************************************************************************
**************** Figures A1-A6: Maps of data coverage **************************
********************************************************************************
bys country_id: egen cumulated_ethg = total(ethg_obs)
recode cumulated_ethg (.=0)
recode cumulated_ethg (3=1)

bys country_id: egen cumulated_lbgi1 = total(lbgi1_obs)
recode cumulated_lbgi1 (.=0)
replace cumulated_lbgi1 =1 if cumulated_lbgi1 >=1

bys country_id: egen cumulated_betweenstd = total(betweenstd_obs)
recode cumulated_betweenstd (.=0)
replace cumulated_betweenstd =1 if cumulated_betweenstd >=1

bys country_id: egen cumulated_SEI = total(SEI_obs)
recode cumulated_SEI (.=0)
replace cumulated_SEI =1 if cumulated_SEI >=1

bys country_id: egen cumulated_ggini = total(ggini_obs)
recode cumulated_ggini (.=0)
replace cumulated_ggini =1 if cumulated_ggini >=1

bys country_id: egen cumulated_low_ratio = total(low_ratio_obs)
recode cumulated_low_ratio (.=0)
replace cumulated_low_ratio =1 if cumulated_low_ratio >=1

spmap cumulated_ethg using "worldcoor" if year==2020, id(map_id) clmethod(unique) fcolor(Greys2) osize(vthin vthin vthin vthin) ndsize(vvthin) title("") graphregion(lcolor(black) lwidth(tiny)) legenda(off)
graph export Figure_A1.png, width(4000) replace

spmap cumulated_low_ratio using "worldcoor" if year==2020, id(map_id) clmethod(unique) fcolor(Greys2) osize(vthin vthin vthin vthin) ndsize(vvthin) title("") graphregion(lcolor(black) lwidth(tiny)) legenda(off) 
graph export Figure_A2.png, width(4000) replace

spmap cumulated_betweenstd using "worldcoor" if year==2020, id(map_id) clmethod(unique) fcolor(Greys2) osize(vthin vthin vthin vthin) ndsize(vvthin) title("") graphregion(lcolor(black) lwidth(tiny)) legenda(off) 
graph export Figure_A3.png, width(4000) replace

spmap cumulated_lbgi1 using "worldcoor" if year==2020, id(map_id) clmethod(unique) fcolor(Greys2) osize(vthin vthin vthin vthin) ndsize(vvthin) title("") graphregion(lcolor(black) lwidth(tiny)) legenda(off) 
graph export Figure_A4.png, width(4000) replace

spmap cumulated_SEI using "worldcoor" if year==2020, id(map_id) clmethod(unique) fcolor(Greys2) osize(vthin vthin vthin vthin) ndsize(vvthin) title("") graphregion(lcolor(black) lwidth(tiny)) legenda(off) 
graph export Figure_A5.png, width(4000) replace

spmap cumulated_ggini using "worldcoor" if year==2020, id(map_id) clmethod(unique) fcolor(Greys2) osize(vthin vthin vthin vthin) ndsize(vvthin) title("") graphregion(lcolor(black) lwidth(tiny)) legenda(off) 
graph export Figure_A6.png, width(4000) replace

****************************************************************
*************** Table A1: Temporal variation *******************
****************************************************************
xtset country_id year
xtsum z_ethg z_low_ratio z_lbgi1 betweenstd z_SEI z_ggini

egen z_poly=std(v2x_polyarchy), mean(0) std(1)



****************************************************
************** Table A2: Non-random patterns  ******
****************************************************

*** GDP
ttest e_migdppcln if year == 2000, by(ethg_obs)
ttest e_migdppcln if year == 2000, by(low_ratio_obs)
ttest e_migdppcln if year == 2000, by(lbgi1_obs)
ttest e_migdppcln if year >= 1996 & year <= 2006, by(betweenstd_obs)
ttest e_migdppcln if year == 2000, by(ggini_obs)

*** Democracy
ttest e_boix_regime if year == 2000, by(ethg_obs)
ttest e_boix_regime if year == 2000, by(low_ratio_obs)
ttest e_boix_regime if year == 2000, by(lbgi1_obs)
ttest e_boix_regime if year >=1996  & year <=2006, by(betweenstd_obs)
ttest e_boix_regime if year == 2000, by(ggini_obs)

*** State Capacity
* resscale
generate state_capacity = ((v2clrspct--4)/(4--4))*(1-0)
ttest state_capacity if year == 2000, by(ethg_obs)
ttest state_capacity if year == 2000, by(low_ratio_obs)
ttest state_capacity if year == 2000, by(lbgi1_obs)
ttest state_capacity if year >=1996  & year <=2006, by(betweenstd_obs)
ttest state_capacity if year == 2000, by(ggini_obs)

/// Country Size
* generate logged land area
gen ln_area = ln(e_area)
ttest ln_area if year == 2000, by(ethg_obs)
ttest ln_area if year == 2000, by(low_ratio_obs)
ttest ln_area if year == 2000, by(lbgi1_obs)
ttest ln_area if year >=1996  & year <=2006, by(betweenstd_obs)
ttest ln_area if year == 2000, by(ggini_obs)




********************************************************************************
************* Tables A3-A6: Additional correlation analysis ********************
********************************************************************************

** Table A3: Report correlations for year 2000 
pwcorr ethg low_ratio lbgi1 betweenstd SEI ggini if year ==2000, obs
matrix list r(C), format(%4.2f)

** Table A4: 1995-2005
pwcorr ethg low_ratio lbgi1 betweenstd SEI ggini if year >=1995 & year <=2005, obs
matrix list r(C), format(%4.2f)


** Table A5: Overlapping group: countries and time
egen coverage_year = rownonmiss(ethg low_ratio lbgi1 betweenstd SEI ggini)
bro if coverage_year >= 4
gen overlap = 1 if coverage_year >= 4

pwcorr ethg low_ratio lbgi1 betweenstd SEI ggini if overlap==1 , obs
matrix list r(C), format(%4.2f)


*** Table A6: 
bys country_id: egen cumulated_coverage = total(coverage_year)

pwcorr ethg low_ratio lbgi1 betweenstd SEI ggini if country_name =="United States" | country_name == "Mexico" | country_name == "Ghana" | country_name == "Colombia" | country_name == "Brazil" | country_name == "Bolivia" | country_name == "Honduras" | country_name == "Mali" | country_name == "Peru" | country_name == "Senegal" | country_name == "Kenya" | country_name == "Phillippines"  | country_name == "Thailand" | country_name == "Benin" | country_name == "Nepal" | country_name == "Nicaragua" | country_name == "Guinea" | country_name == "Chile" | country_name == "Costa Rica" | country_name == "Ecuador" | country_name == "Malawai" | country_name == "Panama" | country_name == "Turkey" | country_name == "Madagascar"| country_name == "Sri Lanka" | country_name == "Trinidad and Tobago" | country_name == ""                     , obs
matrix list r(C), format(%4.2f)


**********************************************************************************
************* Figure A7-A12: Maps with standardized values ***************************
**********************************************************************************

* Figure A7
spmap z_ethg using worldcoor.dta if year ==2000, id(map_id) fcolor(Blues2) osize(vvthin vvthin vvthin vvthin) ndsize(vvthin) clmethod(quantile) title("Alesina et al.")
graph export Figure_A7.png, width(4000) replace

* Figure A8
spmap z_low_ratio using worldcoor.dta if year ==2000, id(map_id) fcolor(Blues2) osize(vvthin vvthin vvthin vvthin) ndsize(vvthin) clmethod(quantile) title("Cederman et al.")
graph export Figure_A8.png, width(4000) replace

* Figure A9
* Prepapre Baldwin and Huber with coverager 1996-2005 for data visualization
g betweenstd_2000 = betweenstd
xfill betweenstd_2000, i(country_id)
spmap z_lbgi1 using worldcoor.dta if year ==2000, id(map_id) fcolor(Blues2) osize(vvthin vvthin vvthin vvthin) ndsize(vvthin) clmethod(quantile) title("")
graph export Figure_A9.png, width(4000) replace

* Figure A10
spmap betweenstd_2000 using worldcoor.dta if year ==2000, id(map_id) fcolor(Blues2) osize(vvthin vvthin vvthin vvthin) ndsize(vvthin) clmethod(quantile) title("")
graph export Figure_A10.png, width(4000) replace

* Figure A11
spmap z_SEI using worldcoor.dta if year ==2000, id(map_id) fcolor(Blues2) osize(vvthin vvthin vvthin vvthin) ndsize(vvthin) clmethod(quantile) title("")
graph export Figure_A11.png, width(4000) replace

* Figure A12
spmap z_ggini using worldcoor.dta if year ==2000, id(map_id) fcolor(Blues2) osize(vvthin vvthin vvthin vvthin) ndsize(vvthin) clmethod(quantile) title("")
graph export Figure_A12.png, width(4000) replace

**************************************************************************
************** Figure A13: Inspection of Alesina et al. and Houle **********
**************************************************************************

set scheme s1mono
twoway (scatter lbgi1 ethg_ip,   		mlabel(country_name) msize(medium) mlabpos(3) mlabsize(2) mlabangle(45)) || (lfit lbgi1 ethg,  clwidth(medthick)), ///
		ytitle("Between-Group Inequality, Houle", size(small)) xlabel(,labsize(small)) xtitle("Ethnic Gini (Ethnologue), Alesina et al.", size(small)) title("", size(medlarge)) subtitle("", size(vsmall)) legend(off) graphregion(color(white)) plotregion(color(white)) yscale(range(0 2.5)) ylabel(0(0.5)2.5) || if year == 2000

graph export Figure_A13.png, width(4000) replace


****************************************************************************
************** Table A7: Standardized scores for selected countries  *******
****************************************************************************

*** Observations for the year 2000 or at available point between 1995-2005 for Baldwin and Huber
browse country_name year z_ethg z_low_ratio z_lbgi1 betweenstd z_SEI z_ggini if year >= 1995 & year <= 2005 & country_name =="Switzerland" 
browse country_name year z_ethg z_low_ratio z_lbgi1 betweenstd z_SEI z_ggini if year >= 1995 & year <= 2005 & country_name =="South Africa" 
browse country_name year z_ethg z_low_ratio z_lbgi1 betweenstd z_SEI z_ggini if year >= 1995 & year <= 2005 & country_name =="Guatemala" 
browse country_name year z_ethg z_low_ratio z_lbgi1 betweenstd z_SEI z_ggini if year >= 1995 & year <= 2005 & country_name =="Peru" 
browse country_name year z_ethg z_low_ratio z_lbgi1 betweenstd z_SEI z_ggini if year >= 1995 & year <= 2005 & country_name =="Brazil" 
browse country_name year z_ethg z_low_ratio z_lbgi1 betweenstd z_SEI z_ggini if year >= 1995 & year <= 2005 & country_name =="Nigeria" 



**************************************************************************
***** Table A8: Correlations of vertical inequaliy measures **************
**************************************************************************

* rescale so high values indicate more inequality
generate ws = ((nwageshare-140.9411)/(1.674932-140.9411)*(1-0)+0)
generate v2peapsecon_rescaled = ((v2peapsecon-3.638)/(-3.062-3.638)*(1-0)+0)

pwcorr gini_disp wdi_gini v2peapsecon_rescaled ws
matrix list r(C), format(%4.2f)




****************************************************************************
******* Table A9: Discriminant validation **********************************
****************************************************************************
clonevar eth_fragm_ip = eth_fragm
xfill eth_fragm_ip, i(country_id)

clonevar ef_ip = ef
xfill ef_ip, i(country_id)


pwcorr ethg gini_disp e_peedgini eth_fragm_ip ef_ip, obs
pwcorr low_ratio gini_disp e_peedgini eth_fragm_ip ef_ip, obs
pwcorr lbgi1 gini_disp e_peedgini eth_fragm_ip ef_ip, obs
pwcorr betweenstd gini_disp e_peedgini eth_fragm_ip ef_ip, obs
pwcorr SEI gini_disp e_peedgini eth_fragm_ip ef_ip, obs
pwcorr ggini gini_disp e_peedgini eth_fragm_ip ef_ip, obs




*********************************************************************
************** Table A10-A11: Replication Alesina et al. 2016 *******
*********************************************************************

*** Table A10 ***

* Ensure sample overlap
replace lnrgdppcch2000 =. if year!=2000

* Replication of Alesina et al. 2016: GDP per capita

xi: areg  lnrgdppcch2000 	z_ethg, a(region) robust
eststo m1

xi: areg  lnrgdppcch2000 	z_low_ratio, a(region) robust
eststo m2

xi: areg  lnrgdppcch2000 	z_lbgi1, a(region) robust
eststo m3

xi: areg  lnrgdppcch2000 	z_SEI, a(region) robust
eststo m4

xi: areg  lnrgdppcch2000 	z_ggini, a(region) robust
eststo m5

  esttab using output_1.rtf, b(3) se(3) se star(* 0.05  ** 0.01 *** 0.001) stats(N r2, fmt(0 3))
  
  eststo clear


*** Check for sample influence: Table A11 ***

reg z_ethg_ip z_low_ratio z_lbgi1 z_SEI z_ggini
generate baseline1 = e(sample)

xi: areg  lnrgdppcch2000 	z_ethg if baseline1 ==1, a(region) robust
eststo m1

xi: areg  lnrgdppcch2000 	z_low_ratio if baseline1 ==1, a(region) robust
eststo m2

xi: areg  lnrgdppcch2000 	z_lbgi1 if baseline1 ==1, a(region) robust
eststo m3

xi: areg  lnrgdppcch2000 	z_SEI if baseline1 ==1, a(region) robust
eststo m4

xi: areg  lnrgdppcch2000 	z_ggini if baseline1 ==1, a(region) robust
eststo m5

	esttab using output_1b.rtf, b(3) se(3) se star(* 0.05  ** 0.01 *** 0.001) stats(N r2, fmt(0 3))
  
	eststo clear



************************************************************
************** Table A12-A13: Replication Houle 2015 *******
************************************************************

*** Table A12 ***

probit autocracy z_ethg_ip lwgi1 c.z_ethg_ip#c.lwgi1 loilincome lethnici lgdptreis lonegrowthtreis lmoslemi lwpch lagedem sizedom western share if ldemocracy==1, cluster(cowcode)
eststo m11

probit autocracy z_low_ratio lwgi1 c.z_low_ratio#c.lwgi1 loilincome lethnici lgdptreis lonegrowthtreis lmoslemi lwpch lagedem sizedom western share if ldemocracy==1, cluster(cowcode)
eststo m12

probit autocracy z_lbgi1 lwgi1 c.z_lbgi1#c.lwgi1 loilincome lethnici lgdptreis lonegrowthtreis lmoslemi lwpch lagedem sizedom western share if ldemocracy==1, cluster(cowcode)
eststo m13

probit autocracy z_SEI lwgi1 c.z_SEI#c.lwgi1 loilincome lethnici lgdptreis lonegrowthtreis lmoslemi lwpch lagedem sizedom western share if ldemocracy==1, cluster(cowcode)
eststo m14

probit autocracy z_ggini lwgi1 c.z_ggini#c.lwgi1 loilincome lethnici lgdptreis lonegrowthtreis lmoslemi lwpch lagedem sizedom western share if ldemocracy==1, cluster(cowcode)
eststo m15

	esttab using output_2.rtf, b(3) se(3) se star(* 0.05  ** 0.01 *** 0.001) stats(N r2, fmt(0 3))

	eststo clear


*** Check for sample influence: Table A13 ***

probit autocracy z_ethg_ip lwgi1 c.z_ethg_ip#c.lwgi1 loilincome lethnici lgdptreis lonegrowthtreis lmoslemi lwpch lagedem sizedom western share if ldemocracy==1 & baseline1==1, cluster(cowcode)
eststo m11

probit autocracy z_low_ratio lwgi1 c.z_low_ratio#c.lwgi1 loilincome lethnici lgdptreis lonegrowthtreis lmoslemi lwpch lagedem sizedom western share if ldemocracy==1 & baseline1==1, cluster(cowcode)
eststo m12

probit autocracy z_lbgi1 lwgi1 c.z_lbgi1#c.lwgi1 loilincome lethnici lgdptreis lonegrowthtreis lmoslemi lwpch lagedem sizedom western share if ldemocracy==1 & baseline1==1, cluster(cowcode)
eststo m13

probit autocracy z_SEI lwgi1 c.z_SEI#c.lwgi1 loilincome lethnici lgdptreis lonegrowthtreis lmoslemi lwpch lagedem sizedom western share if ldemocracy==1 & baseline1==1, cluster(cowcode)
eststo m14

probit autocracy z_ggini lwgi1 c.z_ggini#c.lwgi1 loilincome lethnici lgdptreis lonegrowthtreis lmoslemi lwpch lagedem sizedom western share if ldemocracy==1 & baseline1==1, cluster(cowcode)
eststo m15

	esttab using output_2b.rtf, b(3) se(3) se star(* 0.05  ** 0.01 *** 0.001) stats(N r2, fmt(0 3))

	eststo clear
  
************************************************************************
************** Table A14-A15: Replication Cederman et al. (2013) *************
************************************************************************

*** Table A14 ***

global CONTROLS1 ethfrac lpop lgdppcl 
global TIME1 lonshist pyr_NSA NSA_spl*

logit NSAonset z_ethg_ip sip2l mgini_intx max_rexcll  $CONTROLS1 $TIME1 if year>1990, cl(country_id) nolog
eststo m21

logit NSAonset z_low_ratio sip2l mgini_intx max_rexcll $CONTROLS1 $TIME1 if year>1990, cl(country_id) nolog
eststo m22

logit NSAonset z_lbgi1  sip2l mgini_intx max_rexcll $CONTROLS1 $TIME1 if year>1990, cl(country_id) nolog
eststo m23

logit NSAonset z_SEI sip2l mgini_intx max_rexcll $CONTROLS1 $TIME1 if year>1990, cl(country_id) nolog
eststo m24

logit NSAonset z_ggini sip2l mgini_intx max_rexcll $CONTROLS1 $TIME1 if year>1990, cl(country_id) nolog
eststo m25


	esttab using output_3.rtf, b(3) se(3) se star(* 0.05  ** 0.01 *** 0.001) stats(N r2, fmt(0 3))

	eststo clear



*** Check for sample influence: Table A15 ***


logit NSAonset z_ethg_ip sip2l mgini_intx max_rexcll  $CONTROLS1 $TIME1 if year>1990 & baseline1==1, cl(country_id) nolog
eststo m21

logit NSAonset z_low_ratio sip2l mgini_intx max_rexcll $CONTROLS1 $TIME1 if year>1990 & baseline1==1, cl(country_id) nolog
eststo m22

logit NSAonset z_lbgi1  sip2l mgini_intx max_rexcll $CONTROLS1 $TIME1 if year>1990 & baseline1==1, cl(country_id) nolog
eststo m23

logit NSAonset z_SEI sip2l mgini_intx max_rexcll $CONTROLS1 $TIME1 if year>1990 & baseline1==1, cl(country_id) nolog
eststo m24

logit NSAonset z_ggini sip2l mgini_intx max_rexcll $CONTROLS1 $TIME1 if year>1990 & baseline1==1, cl(country_id) nolog
eststo m25


	esttab using output_3b.rtf, b(3) se(3) se star(* 0.05  ** 0.01 *** 0.001) stats(N r2, fmt(0 3))

	eststo clear

**************************************************************************
************** Table A16-17: Replication Baldwin and Huber (2010) *************
**************************************************************************

*** Table A16 ***

reg pg z_ethg_ip lngdpstd popstd polity2std afrobarom wvs cses, robust
eststo m31

reg pg z_low_ratio lngdpstd popstd polity2std afrobarom wvs cses, robust
eststo m32

reg pg z_lbgi1 lngdpstd popstd polity2std afrobarom wvs cses, robust
eststo m33

reg pg z_SEI lngdpstd popstd polity2std afrobarom wvs cses, robust
eststo m34

reg pg z_ggini lngdpstd popstd polity2std afrobarom wvs cses, robust
eststo m35

reg pg betweenstd lngdpstd popstd polity2std afrobarom wvs cses, robust
eststo m36

	esttab using output_4.rtf, b(3) se(3) se star(* 0.05  ** 0.01 *** 0.001) stats(N r2, fmt(0 3))

	eststo clear


*** Check for sample influence: Table A17 ***

reg z_ethg_ip z_low_ratio z_lbgi1 z_SEI z_ggini betweenstd
generate baseline2 = e(sample)

reg pg z_ethg_ip lngdpstd popstd polity2std afrobarom wvs cses if baseline2 ==1, robust
eststo m31

reg pg z_low_ratio lngdpstd popstd polity2std afrobarom wvs cses if baseline2 ==1, robust
eststo m32

reg pg z_lbgi1 lngdpstd popstd polity2std afrobarom wvs cses if baseline2 ==1, robust
eststo m33

reg pg z_SEI lngdpstd popstd polity2std afrobarom wvs cses if baseline2 ==1, robust
eststo m34

reg pg z_ggini lngdpstd popstd polity2std afrobarom wvs cses if baseline2 ==1, robust
eststo m35

reg pg betweenstd lngdpstd popstd polity2std afrobarom wvs cses if baseline2 ==1, robust
eststo m36

	esttab using output_4b.rtf, b(3) se(3) se star(* 0.05  ** 0.01 *** 0.001) stats(N r2, fmt(0 3))

	eststo clear



*********************************************************************************
************** Table A18: Correlation analysis with additional measures **********
*********************************************************************************

pwcorr ethg grg low_ratio CL_low1_overlap lbgi1 betweenstd SEI ggini, obs
matrix list r(C), format(%4.2f)

	

********************************************************************
************** Figure A14: Index ************************************
********************************************************************

**** Create Index
alpha SEI ethg_ip, generate(index) std
sum index if year ==2000, detail

*Create map: Requires file "worldcoor.dta" in same folder
spmap index using worldcoor.dta if year ==2000, id(map_id) fcolor(Blues2) osize(vvthin vvthin vvthin vvthin) ndsize(vvthin) clmethod(quantile) title("")

graph export Figure_A14.png, width(4000) replace
		
		
****************************************************************************
********* Figure A15: Replication analyses with index: coefplot *************
****************************************************************************

xi: areg  lnrgdppcch2000 	index, a(region) robust
eststo m101

probit autocracy index lwgi1 c.index#c.lwgi1 loilincome lethnici lgdptreis lonegrowthtreis lmoslemi lwpch lagedem sizedom western share if ldemocracy==1, cluster(cowcode)
eststo m102

logit NSAonset index sip2l mgini_intx max_rexcll  $CONTROLS1 $TIME1 if year>1990, cl(country_id) nolog
eststo m103

reg pg index lngdpstd popstd polity2std afrobarom wvs cses, robust
eststo m104

coefplot (m101, label(Index / Alesina et al.)) (m102, label(Index / Houle)) (m103, label(Index / Cederman et al.)) (m104, label(Index / Baldwin and Huber)), keep(index) vertical yline(0) xtitle("") xlabel("") title("") scheme(plottig) graphregion(lcolor(black) lwidth(tiny))

graph export Figure_A15.png, width(4000) replace

